<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="DataLoad.php"-->
<html>
<head>
<title><%=GuildName%> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<%=StylePath%>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<%=StylePath%>/styleplus.js"></script>
<script language="JavaScript" src="inc/UBB_UI.js"></script>
<style type="text/css" media="all">

</style>
<!--#include file="inc/ajax.php"-->
</head>

<body>
<div class="header">
<!--#include file="menu.php"-->
</div>
<div class="main">
<%

if not Isnumeric(request("id")) or request("id")="" then 
	Call RaidList()
else
	if Request("Sub")="delEvents" then 
		Call DelEvents(Request.form("idlist"))
	end if

	'声明变量
	Dim ArrEvents() , ArrPlayers() , attDKP
	Dim RaidName, RaidActionTime , RaidEndTime , RaidReadyTime , ArrRaidPlayer , RaidMaxPlayer , RaidRule , RaidRuleName , RaidClass , RaidStep , RaidNeedPlayer ,RaidPlan
	Dim Numfirstdown , Numfindboss , Numfarmdown
	Dim RuleFirst , RuleFarm , RuleFind , RuleBOE , RuleENC 
	Dim TotalDKP , PraDKP , issue
	Dim HtmlLoot , HtmlEvent , HtmlInfo , HtmlPlayer , HtmlEventGlobal
	'读取数据,变量初始化

	sql="select * from raid where id="&request("id") '读取RAID基本信息
	rs.open sql,conn,1,1
		if Instr(rs("raid_player"),",")<1 then
			Response.write "没有添加活动成员"
			Response.End
		end if
		RaidName = rs("raid_name")
		RaidActionTime = rs("raid_actiontime")
		RaidEndTime = rs("raid_endtime")
		RaidTimeUsed = DateDiff("n",RaidActionTime,RaidEndTime)
		RaidReadyTime = rs("raid_concentratetime")
		ArrRaidPlayer = split(rs("raid_player"),", ")
		RaidMaxPlayer = Ubound(split(rs("raid_player"),", "))
		RaidRule = rs("raid_ruler")
		RaidClass = rs("raid_class")
		RaidStep = rs("raid_step")
		RaidNeedPlayer= rs("raid_personnel")
		RaidPlan = rs("Raid_Plan")
	rs.close

	sql="select * from raid_event where event_raidid="&request("id")&" order by event_time , id desc" '读取RAID事件到数组 ArrEvents(x,5)
	rs.open sql,conn,1,1
		if rs.eof or rs.bof then
			Response.write "<div class='message'>活动没有添加任何事件</div>"
			'Response.end
			ReDim ArrEvents(0,8)
		else
			ReDim ArrEvents(rs.recordcount-1,8)
			Numfirstdown=0
			Numfindboss=0
			Numfarmdown=0
			for i = 0 to rs.recordcount-1
				ArrEvents(i,0)=rs("event_class") '类型
				ArrEvents(i,1)=rs("event_object") '对象玩家
				ArrEvents(i,2)=rs("event_object2") '事物对象
				ArrEvents(i,3)=rs("event_dkp") '涉及DKP
				ArrEvents(i,4)=rs("event_time") '时间
				ArrEvents(i,5)=0 '涉及成员人数
				ArrEvents(i,6)="|" '涉及成员编号表
				ArrEvents(i,7)=rs("event_dkp2") '涉及DKP2
				ArrEvents(i,8)=rs("event_object2_tooltip") '物品tooltip
				Select Case rs("event_class")
					Case "首次"
						Numfirstdown=Numfirstdown+1
					Case "发现"
						Numfindboss=Numfindboss+1
					Case "击杀"
						Numfarmdown=Numfarmdown+1
				End Select
			rs.movenext
			next
		end if
	rs.close

	ReDim ArrPlayers(RaidMaxPlayer,9) '读取玩家信息
	sql="select * from player"
	rs.open sql,conn,1,1
		if rs.eof or rs.bof then
		else
			for i = 1 to rs.recordcount
				for io = 0 to RaidMaxPlayer
					if rs("id")=cint(ArrRaidPlayer(io)) then
						ArrPlayers(io,0)=rs("id")
						ArrPlayers(io,1)=rs("player_name") '成员名字
						ArrPlayers(io,2)=rs("player_guildlevel") '公会职务
						ArrPlayers(io,3)=rs("player_profession") '角色职业
						ArrPlayers(io,4)=rs("player_tribe") '种族
						ArrPlayers(io,5)="" '担任职务,分数
						ArrPlayers(io,6)=0 '本次获得分数
						ArrPlayers(io,7)="" '校验寄存
						ArrPlayers(io,8)="" '加入离开事件集合
						ArrPlayers(io,9)=0 '花费
						
					end if
				next
			rs.movenext
			next
		end if
	rs.close

	'读取DKP规则设置
	 'RuleFirst , RuleFarm , RuleFind , RuleBOE , RuleENC 
	if RaidRule="" or not IsNumeric(RaidRule) then
		'Error
	else
		sql="Select * from ruler where id="&RaidRule
		rs.open sql,conn,1,1
		if rs.bof or rs.eof then
			'Error
			showerror("没有设置该活动的记分规则")
			Response.end
		else
			RaidRuleName = rs("ruler_name")
			RuleAtt = rs("ruler_attendee")
			RuleFirst = rs("ruler_firstdown")
			RuleFarm = rs("ruler_farmdown")
			RuleFind = rs("ruler_findboss")
			RuleBOE = rs("ruler_BOE")
			RuleENC = rs("ruler_ENC")
		end if
		rs.close
	end if


	Call ReportCore()

	Call ShowReport()

	Call Update_lastraid(ArrRaidPlayer,RaidActionTime)

	Call DataUpdate()

	Call GuestBook()
end if
%>
</div>
<div id="footer"><!--#include file="footer.php"--></div>

</body>
</html>
<%

Sub ReportCore()
	Dim EventDelList , EventError
	EventDelList=","
	'检查事件的合法性
	sql="select * from raid_event where event_raidid="&request("id")&" and (event_class='加入' or event_class='离开') order by event_time ,id desc"
	rs.open sql,conn,1,1
		if rs.eof or rs.bof then
		else
			for i = 1 to rs.recordcount
				for j = 0 to Ubound(ArrPlayers,1)
					if cstr(ArrPlayers(j,0))=cstr(rs("event_object")) then
						select case true
							case rs("event_class")="加入"
							ArrPlayers(j,7)=ArrPlayers(j,7)&"1"
							case rs("event_class")="离开"
							ArrPlayers(j,7)=ArrPlayers(j,7)&"0"
						end select
					end if
					if instr(right(ArrPlayers(j,7),2),"00")>0 or instr(right(ArrPlayers(j,7),2),"11")>0 then 
						EventError=EventError & "事件合法性错误,成员 "&ArrPlayers(j,1)&" 的离开或加入事件不合理. "&vbCrlf '不合法
						if Instr(EventDelList,","&rs("id")&",")<1 then EventDelList=EventDelList&rs("id")&","
						'ArrPlayers(j,7)=left(ArrPlayers(j,7),len(ArrPlayers(j,7))-1)
					end if
				next
			rs.movenext
			next
		end if
	rs.close
	if EventError<>"" then
	Response.write "<textarea name='' rows='6' style='width:100%;'>"&EventError&"</textarea><input type='hidden' name='idlist' value='"&EventDelList&"' />"
	end if

	'获取每个事件的参与人数
	for i = 0 to Ubound(ArrEvents,1)
		for j = 0 to Ubound(ArrPlayers,1)
			if chkintime(ArrEvents(i,4),ArrPlayers(j,0),i) then
				ArrEvents(i,5)=ArrEvents(i,5)+1
				ArrEvents(i,6)=ArrEvents(i,6)&ArrPlayers(j,0)&"|"
			end if
		next
	next


	'整理离开加入事件
	Dim Stt,TempEvent , TE2
	for i = 0 to Ubound(ArrPlayers,1)
		Stt=""
		TempEvent=""
		for j = 0 to Ubound(ArrEvents,1)
			if (ArrEvents(j,0)="加入" or ArrEvents(j,0)="离开") and Cstr(ArrEvents(j,1))=Cstr(ArrPlayers(i,0)) then
				if TempEvent="" and ArrEvents(j,0)="加入" then
					TempEvent="J"
				elseif TempEvent="" and ArrEvents(j,0)="离开" then
					TempEvent="L"
				end if
				TempEvent=TempEvent&","&ArrEvents(j,4)
			end if
		next

		ArrPlayers(i,8)=TempEvent
	next

	'累加每个成员所得分数
	for i = 0 to Ubound(ArrPlayers,1)
		for j = 0 to Ubound(ArrEvents,1)
			'活动事件(固定分数)
			if  ArrEvents(j,0)="活动事件" then
				ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
				TotalDKP=TotalDKP+ ArrEvents(j,3)
			end if
			'拾取,仓库,首次,发现,击杀,自定义
			if Instr(ArrEvents(j,6),"|"&ArrPlayers(i,0)&"|")>0 and (ArrEvents(j,0)<>"加入" or ArrEvents(j,0)<>"离开") then
			Select Case True
				Case ArrEvents(j,0)="拾取"
					if ArrEvents(j,7)<>"" and IsNumeric(ArrEvents(j,7)) then
					ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,7)
					else
					ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3) / ArrEvents(j,5)
					end if
					TotalDKP=TotalDKP+ ArrEvents(j,3) / ArrEvents(j,5)
					if  Cstr(ArrPlayers(i,0))=Cstr(ArrEvents(j,1)) then 
						ArrPlayers(i,6) = ArrPlayers(i,6) - ArrEvents(j,3)
						ArrPlayers(i,9) = ArrPlayers(i,9) - ArrEvents(j,3)
						issue=issue+ArrEvents(j,3)
					end if
				Case ArrEvents(j,0)="个人事件"
					if  Cstr(ArrPlayers(i,0))=Cstr(ArrEvents(j,1)) then 
						ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
						TotalDKP=TotalDKP+ ArrEvents(j,3)
					end if
				Case ArrEvents(j,0)="职务任命"
					if  Cstr(ArrPlayers(i,0))=Cstr(ArrEvents(j,1)) then 
						ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
						ArrPlayers(i,5) = ArrPlayers(i,5)&ArrEvents(j,2)&","&ArrEvents(j,3)&"|"
						TotalDKP=TotalDKP+ ArrEvents(j,3)
					end if
				Case ArrEvents(j,0)="仓库"
					if ArrEvents(j,3)<>0 then
						ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
						TotalDKP=TotalDKP+ ArrEvents(j,3)
					else
						ArrPlayers(i,6) = ArrPlayers(i,6) + RuleBOE
						TotalDKP=TotalDKP+ RuleBOE
						ArrEvents(j,3)=RuleBOE
					end if	
'						ArrPlayers(i,6) = ArrPlayers(i,6) + RuleBOE
'						TotalDKP=TotalDKP+ RuleBOE
				Case ArrEvents(j,0)="分解"
					if ArrEvents(j,3)<>0 then
						ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
						TotalDKP=TotalDKP+ ArrEvents(j,3)
					else
						ArrPlayers(i,6) = ArrPlayers(i,6) + RuleENC
						TotalDKP=TotalDKP+ RuleENC
						ArrEvents(j,3)=RuleENC
					end if	
					'ArrPlayers(i,6) = ArrPlayers(i,6) + RuleENC
					'TotalDKP=TotalDKP+ RuleENC
				Case ArrEvents(j,0)="首次"
					if ArrEvents(j,3)<>0 then
						ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
						TotalDKP=TotalDKP+ ArrEvents(j,3)
					else
						ArrPlayers(i,6) = ArrPlayers(i,6) + RuleFirst
						TotalDKP=TotalDKP+ RuleFirst
						ArrEvents(j,3)=RuleFirst
					end if
				Case ArrEvents(j,0)="发现"
					if ArrEvents(j,3)<>0 then
						ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
						TotalDKP=TotalDKP+ ArrEvents(j,3)
					else
						ArrPlayers(i,6) = ArrPlayers(i,6) + RuleFind
						TotalDKP=TotalDKP+ RuleFind
						ArrEvents(j,3)=RuleFind
					end if
				Case ArrEvents(j,0)="击杀"
					if ArrEvents(j,3)<>0 then
						ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
						TotalDKP=TotalDKP+ ArrEvents(j,3)
					else
						ArrPlayers(i,6) = ArrPlayers(i,6) + RuleFarm
						TotalDKP=TotalDKP+ RuleFarm
						ArrEvents(j,3)=RuleFarm
					end if
				Case ArrEvents(j,0)="团队事件"
					ArrPlayers(i,6) = ArrPlayers(i,6) + ArrEvents(j,3)
					TotalDKP=TotalDKP+ ArrEvents(j,3)
			End Select
			end if
		next
			if len(ArrPlayers(i,8))>1 then
				ArrPlayers(i,6) = ArrPlayers(i,6) + RuleAtt/2
				TotalDKP=TotalDKP+ RuleAtt/2
			else
				ArrPlayers(i,6) = ArrPlayers(i,6) + RuleAtt
				TotalDKP=TotalDKP+ RuleAtt
			end if
	'	TotalDKP=TotalDKP+Cint(ArrPlayers(i,6))
	'	Response.write ArrPlayers(i,1)&" : "&Int(ArrPlayers(i,6))&"<br>"
	next



End Sub

Sub ShowReport()
	'显示基本信息
	HtmlInfo=HtmlInfo&"<table class=' outframe interlace'>"
	HtmlInfo=HtmlInfo&"<tr><th colspan='6'><div class='title'><img src='images/icon/banner.jpg' width='64' height='64'>活动:"&RaidName&"</div><div class='filter'>"
	if CheckAdmin() and RaidStep<3 then HtmlInfo=HtmlInfo&"<a href='admin_raid.php?action=edit&amp;id="&request("id")&"' class='abtn3'>修改基本信息</a> <a href='admin_report.php?action=collect&id="&request("id")&"' class='abtn3'>编辑活动人员</a> <a href='admin_report.php?action=collect2&id="&request("id")&"' class='abtn3'>编辑活动事件</a>"
	HtmlInfo=HtmlInfo&" <form method='post' action='raid_report.php' name='form22'>"&selectraid()&"</form> </div></th></tr>"&vbCrlf
	HtmlInfo=HtmlInfo&"<tr><td>开始:"&RaidActionTime&"</td><td>结束:"&RaidEndTime&"</td><td>历时:"&formattime(RaidTimeUsed)&"</td><td>参加人数:"&RaidMaxPlayer+1&"人</td><td>DKP制度:"&RaidRuleName&"</td><td><b>"&LogicM(RaidStep,"0|1|3","草稿|报告未归档|报告已归档","|")&"</b></td></tr>"
	HtmlInfo=HtmlInfo&"<tr><td>拓荒"&Numfirstdown&"</td><td>-</td><td>击杀"&Numfarmdown&"</td><td>-</td><td>DKP分类:"&raidclassText(raidclass)&"</td><td>-</td></tr>"
	HtmlInfo=HtmlInfo&"<tr><td colspan='6'>"&RaidPlan&"</td></tr>"
	HtmlInfo=HtmlInfo&""
	HtmlInfo=HtmlInfo&"</table>"

	Response.write HtmlInfo


	'显示物品获取表
	HtmlLoot=HtmlLoot&"<table class='lootlist outframe'>"
	HtmlLoot=HtmlLoot&"<tr><th><div class='title'><img src='images/icon/box.jpg' width='64' height='64'>物品掉落</div><div class='filter'></div></th></tr><tr><td>"
	for i = 0 to Ubound(ArrEvents,1)
		Select Case ArrEvents(i,0)
			Case "拾取"
				if ArrEvents(i,7)<>"" then
					HtmlLoot=HtmlLoot&"<div class='item'><div class='dkp'>"&ArrEvents(i,3)&"/"&ArrEvents(i,7)&"</div>"&eqpic(ArrEvents(i,2),ArrEvents(i,8))&"<div class='itemname'>"&delItemID(ArrEvents(i,2))&"</div><div class='target'>"&id2name2(ArrEvents(i,1))&"</div><div class='time'>"&time_type(ArrEvents(i,4),4)&"</div></div>" &vbCrlf
					PraDKP=PraDKP+ArrEvents(i,3)
				else
					HtmlLoot=HtmlLoot&"<div class='item'><div class='dkp'>"&ArrEvents(i,3)&"</div>"&eqpic(ArrEvents(i,2),ArrEvents(i,8))&"<div class='itemname'>"&delItemID(ArrEvents(i,2))&"</div><div class='target'>"&id2name2(ArrEvents(i,1))&"</div><div class='time'>"&time_type(ArrEvents(i,4),4)&"</div></div>" &vbCrlf
					PraDKP=PraDKP+ArrEvents(i,3)
				end if
			Case "仓库"
				HtmlLoot=HtmlLoot&"<div class='item'><div class='dkp'>"&RuleBOE&"/a</div>"&eqpic(ArrEvents(i,2),ArrEvents(i,8))&"<div class='itemname'>"&delItemID(ArrEvents(i,2))&"</div><div class='target'>仓库</div><div class='time'>"&time_type(ArrEvents(i,4),4)&"</div></div>" &vbCrlf
				PraDKP=PraDKP+RuleBOE*ArrEvents(i,5)
			Case "分解"
				HtmlLoot=HtmlLoot&"<div class='item'><div class='dkp'>"&RuleENC&"/a</div>"&eqpic(ArrEvents(i,2),ArrEvents(i,8))&"<div class='itemname'>"&delItemID(ArrEvents(i,2))&"</div><div class='target'>分解</div><div class='time'>"&time_type(ArrEvents(i,4),4)&"</div></div>" &vbCrlf
				PraDKP=PraDKP+RuleENC*ArrEvents(i,5)
		End Select
	next
	HtmlLoot=HtmlLoot&""
	HtmlLoot=HtmlLoot&""
	HtmlLoot=HtmlLoot&"</td></tr>"
	HtmlLoot=HtmlLoot&"</table>"
	Response.write HtmlLoot

	'显示事件表
	HtmlEvent=HtmlEvent&"<div class='c'>"
		for i = 0 to Ubound(ArrEvents,1)
			Select Case ArrEvents(i,0)
				Case "拾取"
					if ArrEvents(i,7)<>"" then
						HtmlEvent=HtmlEvent&"<div class='tline_looted"&getRndNumber(1,5)&"'>"&PerTimeIMG(RaidActionTime,ArrEvents(i,4))&"<img src='"&StylePath&"/images/event1.gif' class='eventico' alt='<h4>拾取: "&ArrEvents(i,2)&"</h4><p>"&ArrEvents(i,4)&"<br>"&id2name2(ArrEvents(i,1))&" "&ArrEvents(i,3)&"分获得<br>团队共"&ArrEvents(i,5)&"人. 每人<b>"&ArrEvents(i,7)&"</b>分</p>'></div>"
					else
						HtmlEvent=HtmlEvent&"<div class='tline_looted"&getRndNumber(1,5)&"'>"&PerTimeIMG(RaidActionTime,ArrEvents(i,4))&"<img src='"&StylePath&"/images/event1.gif' class='eventico' alt='<h4>拾取: "&ArrEvents(i,2)&"</h4><p>"&ArrEvents(i,4)&"<br>"&id2name2(ArrEvents(i,1))&" "&ArrEvents(i,3)&"分获得<br>团队共"&ArrEvents(i,5)&"人. 每人<b>"&FormatNumber(ArrEvents(i,3)/ArrEvents(i,5),2,-1)&"</b>分</p>'></div>"
					end if
				Case "仓库"
					HtmlEvent=HtmlEvent&"<div class='tline_nulllooted"&getRndNumber(1,3)&"'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'><img src='"&StylePath&"/images/event2.gif' class='eventico' alt='<h4>仓库: "&ArrEvents(i,2)&"</h4><p>"&ArrEvents(i,4)&"<br>"&id2name2(ArrEvents(i,1))&"<br>每人<b>"&ArrEvents(i,3)&"</b>分</p>'></div>"
				Case "分解"
					HtmlEvent=HtmlEvent&"<div class='tline_nulllooted"&getRndNumber(1,3)&"'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'><img src='"&StylePath&"/images/event2.gif' class='eventico' alt='<h4>分解: "&ArrEvents(i,2)&"</h4><p>"&ArrEvents(i,4)&"<br>"&id2name2(ArrEvents(i,1))&"<br>每人<b>"&ArrEvents(i,3)&"</b>分</p>'></div>"
				Case "发现"
					HtmlEvent=HtmlEvent&"<div class=''><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'><img src='"&StylePath&"/images/event3.gif' class='eventico' height='10px' width='10px' alt='<h4>"&ArrEvents(i,2)&"</h4><p>"&ArrEvents(i,4)&"<br>发现</p>'></div>"
				Case "首次"
					HtmlEvent=HtmlEvent&"<div class='tline_killed'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'><img src='"&StylePath&"/images/event4.gif' class='eventico' alt='<h4>"&ArrEvents(i,2)&"</h4><p>"&ArrEvents(i,4)&"<br>首次击杀!!</p>'></div>"
				Case "击杀"
					HtmlEvent=HtmlEvent&"<div class='tline_killed'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'><img src='"&StylePath&"/images/event5.gif' class='eventico' alt='<h4>"&ArrEvents(i,2)&"</h4><p>"&ArrEvents(i,4)&"<br>击杀成功,每人"&ArrEvents(i,3)&"分</p>'></div>"
				Case "团队事件"
					HtmlEvent=HtmlEvent&"<div class='tline_team'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'><img src='"&StylePath&"/images/event6.gif' class='eventico' alt='<h4>团队事件</h4><p>"&ArrEvents(i,4)&"<br>"&ArrEvents(i,2)&"<br>每人"&ArrEvents(i,3)&"分</p>'></div>"
				Case "个人事件"
					HtmlEvent=HtmlEvent&"<div class='tline_personal'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'><img src='"&StylePath&"/images/event7.gif' class='eventico' alt='<h4>个人事件</h4><p>"&ArrEvents(i,4)&"<br>"&id2name2(ArrEvents(i,1))&"<br>"&ArrEvents(i,2)&" "&ArrEvents(i,3)&"分</p>'></div>"
				Case "活动事件"
					HtmlEventGlobal=ArrEvents(i,2)&":"&ArrEvents(i,3)&"分 "
			End Select
		next
	HtmlEvent= vbctrf&"<div class='timeline outframe'><h3>物品和事件 ["&HtmlEventGlobal&"]</h3>"&HtmlEvent
	HtmlEvent=HtmlEvent&"</div>"
	HtmlEvent=HtmlEvent&"</div>"
	Response.write HtmlEvent

	'显示成员出勤表
	Dim ArrJL , JL2 , Rto , AllRto
	HtmlPlayer=HtmlPlayer&"<table class='raidline outframe'>"
	HtmlPlayer=HtmlPlayer&"<tr><th><div class='title'><img src='images/icon/human_f.gif' width='64' height='64'>人员出勤</div></th></tr>"
	for i = 0 to Ubound(ArrPlayers,1)
		AllRto=0
		HtmlPlayer=HtmlPlayer&"<tr><td>"
		HtmlPlayer=HtmlPlayer&"<div class='single'>"

		HtmlPlayer=HtmlPlayer&"<span><img src='"&getProfessionSmallIco(ArrPlayers(i,3))&"' />"&id2name(ArrPlayers(i,0))&office2img(ArrPlayers(i,5))&"</span>"
			if ArrPlayers(i,8)="" then
				HtmlPlayer=HtmlPlayer&"<img src='"&StylePath&"/images/gall.gif' height='20px' width='100%' alt='全程'/>"
			else
				ArrJL=split(Arrplayers(i,8),",")
				for j = 1 to Ubound(ArrJL)
					if j+1 > Ubound(ArrJL) then
						JL2=RaidEndTime
						Rto=PerTime(ArrJL(j),JL2)
					else
						JL2=ArrJL(j+1)
						Rto=PerTime(ArrJL(j),JL2)
					end if
					AllRto=AllRto + Rto
					if j=1 then HtmlPlayer=HtmlPlayer&"<img src='"&StylePath&"/images/"&GAorGB(ArrJL(0),0)&"' height='20px' width='"&PerTime(RaidActionTime,ArrJL(j))&"%' alt='"&PerTime(RaidActionTime,ArrJL(j))&"% "&TimeValue(RaidActionTime)&" - "&TimeValue(ArrJL(j))&"'/>"
					HtmlPlayer=HtmlPlayer&"<img src='"&StylePath&"/images/"&GAorGB(ArrJL(0),j)&"' height='20px' width='"&Rto&"%' alt='"&Rto&"% "&TimeValue(ArrJL(j))&" - "&TimeValue(JL2)&"'/>"
				next
			end if
		HtmlPlayer=HtmlPlayer&"<h6>"
		HtmlPlayer=HtmlPlayer&FormatNumber(ArrPlayers(i,6),2,-1)
		if CInt(ArrPlayers(i,9))<>0 then HtmlPlayer=HtmlPlayer&" (花费:"&Abs(CInt(ArrPlayers(i,9)))&")"
		HtmlPlayer=HtmlPlayer&"</h6>"
		issue =issue+ArrPlayers(i,6)
		HtmlPlayer=HtmlPlayer&"</div>"
		HtmlPlayer=HtmlPlayer&"</td></tr>"
	next
	HtmlPlayer=HtmlPlayer&"<tr><th>分配:"&Int(issue)&" 实际产生: "&PraDKP&" 增长量: "&CInt(issue - PraDKP)&"</th></tr>"
	HtmlPlayer=HtmlPlayer&"</table>"
	response.write HtmlPlayer
End Sub



Sub RaidList()
	response.write "			<table class=' outframe'>"
	response.write "<tr><th colspan='7'><div class='title'><img src='images/icon/axe.jpg'>活动列表</div><div class='filter'>"&selectraid2()&"</div></th></tr>"
	response.write "			<tr class='coltitle'>"
	response.write "				<td widtd='35px'></td>"
	response.write "				<td>分类</td>"
	response.write "				<td>活动</td>"
	response.write "				<td>时间</td>"
	response.write "				<td>历时</td>"
	response.write "				<td>指挥</td>"
	response.write "				<td width='40%'>备注</td>"
	response.write "			</tr>"

		if request.form("filter")<>"" then
			select case true
				case request.form("filter")="all"
					sql="select * from raid Order by raid_actiontime desc"
				case request.form("filter")="edit"
					sql="select * from raid where raid_step<1 Order by raid_actiontime desc"
				case request.form("filter")="end"
					sql="select * from raid where raid_step>1 Order by raid_actiontime desc"
				case left(request.form("filter"),1)="D"
					sql="select * from raid where raid_class="&Mid(request.form("filter"),2)&" Order by raid_actiontime desc"
				case left(request.form("filter"),1)="R"
					sql="select * from raid where raid_ruler='"&Mid(request.form("filter"),2)&"' Order by raid_actiontime desc"
			end select
		else
			sql="select * from raid where raid_step>0 Order by raid_actiontime desc"
		end if

	rs.open sql,conn,1,1
		if rs.bof or rs.eof then
			response.write "<tr><td colspan='7' >没有找到链接项</td></tr>"
		else	
			If request("page") > 0 Then rs.move (request("page")-1)*20
			for i = 1 to 20
				Response.write "<tr class='"&linec(i)&"'>"
				Response.write "<td>"&raidpic(rs("raid_name"))&"</td>"
				Response.write "<td>"&raidclassText(rs("raid_class"))&"</td>"
				Response.write "<td>"&LogicM(rs("raid_step"),"1,2,3",",,已归档",",")&"<a href='?id="&rs("id")&"'>"&rs("raid_name")&"</a></td>"
				Response.write "<td>"&time_type(rs("raid_actiontime"),66)&"</td>"
				Response.write "<td><b>"&formattime(DateDiff("n",rs("raid_actiontime"),rs("raid_endtime")))&"</b></td>"
				Response.write "<td>"&rs("raid_commander")&"</td>"
				Response.write "<td>"&rs("raid_plan")&"</td>"
				Response.write "</tr>"
				rs.movenext
			if rs.eof then exit for
			next
		end If
	response.write "</table>"
	Response.write pages(rs,20,"","10")
	rs.close
End Sub


Sub Update_lastraid(arrPid,sdate)
	'更新成员最后一次参加的日期
	Dim pid
	pid=join(arrPid,"|")
	sql="select * from player"
	rs.open sql,conn,1,1
		if rs.bof or rs.eof then
		else
			for i = 1 to rs.recordcount
			'Response.write pid
			'Response.write rs("player_name")&Datediff("d",rs("player_lastraid"),sdate)&","
				if rs("player_lastraid")="" or Isnull(rs("player_lastraid")) then
					if Instr("|"&pid,"|"&rs("id")&"|")>0  then
						conn.execute("update player set player_lastraid=#"&sdate&"# where id="&rs("id"))
					end if						
				else
					if Instr("|"&pid,"|"&rs("id")&"|")>0 and (Datediff("d",rs("player_lastraid"),sdate)>0) then
						conn.execute("update player set player_lastraid=#"&sdate&"# where id="&rs("id"))
					end if
				end if
			rs.movenext
			next
		end if
	rs.close
End Sub


Function selectraid()
	Dim stext
	sql="select top 20 * from raid order by id desc"
	rs.open sql,conn,1,1
	stext=stext& "<select name='id' onChange='javascript:submit();''>"
	stext=stext& "<option value=''>选择Raid</option>"
	if not (rs.eof or rs.bof) then
		for i = 1 to rs.recordcount
		stext=stext& "<option value='"&rs("id")&"'>"&time_type(rs("raid_actiontime"),3)&" - "&rs("raid_name")&"</option>"
		rs.movenext
		next
	end if
	stext=stext& "<option value='More'>More...</option>"
	stext=stext& "</select>"
	selectraid=stext
	rs.close
End function













'返回"加入"或"离开"的逻辑图片名称
Function GAorGB(F,N)
	if Int(N/2) = N/2 then
		if F="J" then
			GAorGB="gb.gif"
		else
			GAorGB="ga.gif"
		end if
	else
		if F="L" then
			GAorGB="gb.gif"
		else
			GAorGB="ga.gif"
		end if
	end if
End Function


'检查t事件发生时pid成员是否在团队,N是该事件的索引
Function chkintime(t,pid,N)
	chkintime=False
	Dim Tn
	Tn=N
	'向前查找,
	if N>0 then 
		for k= N to 0 step -1
		'	Response.write ArrEvents(Tn,1)&":"&pid&"<br>"  
			if ArrEvents(Tn,0)="离开" and Cstr(ArrEvents(Tn,1))=Cstr(pid) then
				Exit Function
			elseif ArrEvents(k,0)="加入" and Cstr(ArrEvents(k,1))=Cstr(pid) then
				chkintime=True
				Exit Function
			end if
			Tn=Tn-1
		next
	end if
	'向后查找
	if N<Ubound(ArrEvents,1) then
		for k = N+1 to Ubound(ArrEvents,1)
			if ArrEvents(k,0)="加入" and Cstr(ArrEvents(k,1))=Cstr(pid) then
				Exit Function
			elseif ArrEvents(k,0)="离开" and Cstr(ArrEvents(k,1))=Cstr(pid) then
				chkintime=True
				Exit Function
			end if
		next
	end if
	chkintime=True
End Function


'返回两个时间相距对于总时间的百分比
Function PerTime(st,et)
	Dim EventTimeUsed
	EventTimeUsed=DateDiff("n",st,et)
	PerTime=int((EventTimeUsed/RaidTimeUsed)*100)
	if PerTime>=100 then PerTime=99
	if PerTime>98 then PerTime=98
End Function

'PerTime加强版,直接生成长度IMG,另加一个小数部分估算补值
Function PerTimeIMG(st,et)
'<div class='tline_killed'><img src='"&StylePath&"/images/gb.gif' height='1px' width='"&PerTime(RaidActionTime,ArrEvents(i,4))&"%'>
	Dim EventTimeUsed ,PerTimeDec ,PerTime
	EventTimeUsed=DateDiff("n",st,et)
	PerTime=int((EventTimeUsed/RaidTimeUsed)*100)
	if PerTime>=100 then PerTime=99
	if PerTime>98 then PerTime=98
	PerTimeDec = ( EventTimeUsed/RaidTimeUsed*100 - PerTime ) * 10 '精度补值
	PerTimeIMG = "<img src='style/images/gb.gif' height='1px' width='"&PerTime&"%'>" & "<img src='style/images/gb.gif' height='1px' width='"&PerTimeDec&"px'>"
End Function



'更新DKP缓存表
Sub DataUpdate()
	if not (RaidStep="3") then
		sql="select * from dkplist where raidid="&request("id")
		rs.open sql,conn,1,1
		if rs.recordcount = RaidMaxPlayer+1 then
			rs.close
			for i = 0 to RaidMaxPlayer
				if ArrPlayers(i,0)<>"" then
				conn.execute("update dkplist set dkp="&ArrPlayers(i,6)&" where playerid="&ArrPlayers(i,0)&" and raidid="&request("id"))
				end if
			next
		else
			rs.close
			'删除
			sql="Delete * from dkplist where raidid="&request("id")
			conn.execute (sql)
			'再添加
			sql="select * from dkplist where raidid="&request("id")
			rs.open sql,conn,1,3
				for i = 0 to RaidMaxPlayer
					rs.addnew
					rs("playerid")=ArrPlayers(i,0)
					rs("raidid")=request("id")
					rs("dkp")=ArrPlayers(i,6)
					rs.update
				next
			rs.close
		end if
	else
		response.write "End"
	end if
End Sub

Sub DelEvents(idlist)
	Dim ilist
	ilist=split(idlist,",")
	for k = 1 to Ubound(ilist)-1
		Conn.execute("Delete From Raid_event where id="&ilist(k))
	next
End Sub



Sub GuestBook()
	if lvlGBook=0 or lvlGBook<>3 then exit sub
	Response.write "<div class='info outframe'>"
	Response.write "<h3>公会动态</h3>"

	sql="select * from gbook where gbook_raidid='"&request("id")&"' order by id"
	rs.open sql,conn,1,1
		if rs.eof or rs.bof then
			response.write "没有留言"
		else
			for ig = 1 to 8
				response.write "<div class='"&linec(ig)&"'>"
				response.write "<h4>"&htmlencode2(rs("gbook_poster"))&"</h4>"
				if CheckAdmin() then 
				response.write "<p>"&htmlencode2((rs("gbook_content")))&" <span>[<a href='admin_guest.php?del="&rs("id")&"'>删除</a>]</span></p>"
				else
				response.write "<p>"&htmlencode2((rs("gbook_content")))&"</p>"
				end if
				response.write "</div>"
			rs.movenext
			if rs.eof then exit for
			next
		end if
	rs.close
	response.write "<form name='put_log' method='post' action='gbook.php?action=raidadd'>Name: <input type='text' name='gb_author' size='20' value='' /><br>"
	response.write "<textarea name='gb_text' rows='5' cols='60' id='l_content'></textarea>"
	response.write "<input type='hidden' name='gbook_id' value='"&request("id")&"' /><input type='submit' value='留 言' /></form>"
	Response.write "</div>"
End Sub
%>